//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CDepthRenderTarget9.h>
///	@path	~/src/graphics/dx9/
///	@date	2008/09/20
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/dx9/CDevice9.h"
#include "graphics/IRenderTarget.h"

namespace xeres {
	
	/*! 
		\class	CDepthRenderTarget9
		\brief
	*/
	class CDepthRenderTarget9 : public IRenderTarget
	{
	public:

		/// \ctor
		CDepthRenderTarget9( IDirect3DSurface9 * depthStencil );

		/// \dtor
		virtual ~CDepthRenderTarget9( void );

		DECL_IOBJECT_CLASS( CDepthRenderTarget9 , IRenderTarget );

	public:

		/// \name Render target interface.
		//@{

		/// \impl
		virtual bool OnLostDevice( void );

		/// \impl
		virtual bool OnResetDevice( RefWeak<IDevice> device );

		/// \impl
		virtual TextureType GetType( void );

		/// \impl
		virtual DXFormat GetFormat( void );

		/// \impl
		virtual Pair<int> GetSize( void );

		/// \impl
		virtual size_t GetDepth( void );

		/// \impl
		virtual bool Map( uint sub , ResourceMap& data );

		/// \impl
		virtual bool ReadBack( uint sub , ResourceMap& data , bool readonly );

		/// \impl
		virtual bool Unmap( uint sub );

		/// \impl
		virtual bool ApplyTarget( RefWeak<IDevice> device );

		/// \impl
		virtual bool Update( uint sub , const Box<uint>& size , const byte * data , uint row_pitch , uint depth_pitch );

		/// \impl
		virtual IUnknown * GetTextureInterface( void );

		/// \impl
		virtual IUnknown * GetRenderTargetInterface( void );

		//@}

	private:

		// @data
		IDirect3DSurface9 *		m_surface;
		D3DSURFACE_DESC			m_desc;
	};

} // namespace xeres
